Previous Book Contents Book Index Next

Inside Macintosh: Mac OS 8 Toolbox Reference /
Chapter 2 - Control Manager Reference / Control Manager Functions
Accessing and Changing Control Settings and Data /


GetBestControlRect

NEW WITH THE APPEARANCE MANAGER

Determines a control's optimal size and text placement.

pascal OSErr GetBestControlRect (
                     ControlHandle inControl,
                     Rect *outRect,
                     SInt16 *outBaseLineOffset);
inControl
On input, a handle to the control whose size you wish to determine.
outRect
On input, a pointer to the control rectangle you wish to modify; pass an empty rectangle (0, 0, 0, 0). On output, a pointer to the rectangle that the control has determined to be optimal. If the control doesn't support getting an optimal size rectangle, the control's bounding rectangle is passed back.
outBaseLineOffset
On output, the offset from the bottom of control to the base of the text (usually a negative value). If the control doesn't support optimal sizing or has no text, 0 is passed back.
function result
A result code; see "Result Codes".
DISCUSSION
The GetBestControlRect function should be called to automatically position and size controls in accordance with human interface guidelines. This function is particularly helpful in determining the correct placement of control text whose length is not known until run-time. For example, StandardAlert uses GetBestControlRect to automatically size and position buttons in a newly created alert box.

SEE ALSO
"Appearance Manager Gestalt Selector Constants".


Previous Book Contents Book Index Next

© Apple Computer, Inc.
8 JAN 1998